#include "SocketMgr.h"


SocketMgr::SocketMgr(void)
{
}


SocketMgr::~SocketMgr(void)
{
}

bool SocketMgr::initSocket( std::string ip, short adport )
{
	ClientSocket::InitSocket();
	_clientSocket.registerCallBack(this, &SocketMgr::recvMsg);
	return _clientSocket.connection(ip, adport);
}

void SocketMgr::recvMsg( void* data )
{
	TagNetMsg* msg  =  (TagNetMsg*)data;
	char buff[8]={0};
	snprintf(buff, 8, "%d", msg->cmd);
	_eventContainer.snedEvent(buff, data);
}

void SocketMgr::sendMsg( TagNetMsg* data )
{
	int i  = _clientSocket.sendMsg(data, data->size);
}
